const { db } = require('../config')
const { command } = require('../config')
const { workorder_collection } = require('../config')
const _ = command
const common = require('./common');
exports.main = async (event, context) => {
    const data = event;
    // 根据筛选条件查询工单
    const info = await db.collection(workorder_collection).doc(data.id).get()
    // 返回可以驳回的流程
    var wOData = info.data[0];
    const currentProcess = wOData.currentProcess;
    var disAgreeProcess;
    if (wOData.type == '综调发起') {
        const currentIndex = common.zdProcess.indexOf(currentProcess);
        const previousProcesses = common.zdProcess.slice(0, currentIndex);
        disAgreeProcess = previousProcesses;
    } else {
        const currentIndex = common.bzProcess.indexOf(currentProcess);
        const previousProcesses = common.bzProcess.slice(0, currentIndex);
        disAgreeProcess = previousProcesses;
    }
    wOData['disAgreeProcess'] = disAgreeProcess;
    return wOData;
}
